﻿using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web.UI;

namespace DynamicImageCreation
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var objBitMap = new Bitmap(640, 480);
            var objGraphics = Graphics.FromImage(objBitMap);
            objGraphics.Clear(Color.Teal);
            objGraphics.DrawLine(new Pen(Color.Red),0,0,200,200);
            objGraphics.DrawLine(new Pen(Color.DarkBlue), 10, 20, 180, 160);
            objGraphics.DrawString("This PNG was totally generated", new Font("Georgia", 14, FontStyle.Bold), SystemBrushes.WindowText, new PointF(10, 40));
            objBitMap.Save(Response.OutputStream, ImageFormat.Gif);
            objBitMap.Dispose();
            objGraphics.Dispose();
        }
    }
}